
#ifndef __MOS_UTIL_H
#define __MOS_UTIL_H

#ifdef __cplusplus
extern "C" {
#endif


#include "mos_def.h"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#define _GNU_SOURCE

//系统函数
//extern void *calloc (size_t __nmemb, size_t __size);
//extern void *malloc(size_t __size);
//extern void *realloc (void *__ptr, size_t __size);
//extern void *memset (void *__s, int __c, size_t __n);
//extern void *memcpy (void *__dest ,const void *__src, size_t __n);
//extern int memcmp (const void *__s1,const void *__s2,size_t __n);
//extern void free(void *__ptr);
//----------------------------------------------------------

//extern size_t strlen (const char *s);
//extern int  strncasecmp(const char *__s1,const char *__s2,size_t __n);
//extern int  strcasecmp (const char *__s1, const char *__s2);
#ifndef strcmp 
#define strcmp strcmp
#endif
#ifndef strncmp
#define strncmp strncmp
#endif
extern char *strncat(char *dest,const char *src,size_t n);
extern char *strncpy(char *dest,const char *src,size_t n);
extern char *strstr(const char *haystack,const char *needle);
extern int sprintf( char *str,const char * format,...);
extern int printf(const char * format,...);

//内存申请出错
#define util_ptr_chk_exit(p) \
{\
    if(NULL == p)\
    {\
        DEBUG( "malloc failed!");\
        exit(-1);\
    }\
}

//------------------------------------------
extern int close(int fd);


//桩函数，去掉告警
#define  util_alarm_assert(ptr) do{break;}while(ptr)

#define DEBUG(format,args...)\
    printf("[%s %s-%d]:" format "\n",__FILE__,__FUNCTION__,__LINE__,##args)


//转守护进程
BOOL util_daemon_init();
//获取进程名称
SPTR util_getProcessName(SPTR argv0);
SPTR util_getFileName(const SPTR fPath, S8 dim);

#ifdef __cplusplus
}
#endif

#endif  /* __MOS_UTIL_H */
